package jym.tan.tmdb.method.get;

import java.net.URL;

import jym.tan.tmdb.TMDB;
import jym.tan.tmdb.constant.TMDBConstants;
import jym.tan.tmdb.method.Base;
import jym.tan.tmdb.bean.MovieInfo;

/**
 * The Class LatestMovie. This class is similar to the <b>Latest Movie</b> method described in 
 * <a href="http://help.themoviedb.org/kb/api/latest-movie">Latest Movie</a>.
 * This method is used to retrieve the newest movie that was added to TMDb.
 * @author Tanmoy
 */
public class LatestMovie extends Base {

	/**
	 * Instantiates a new LatestMovie.
	 *
	 * @param tmdb the tmdb
	 */
	public LatestMovie(TMDB tmdb) {
		super(tmdb, TMDBConstants.LATEST_MOVIE);
	}

	/**
	 * Gets a {@link MovieInfo} object.
	 *
	 * @return 
	 * 		The <code>MovieInfo</code> object
	 * @throws Exception 
	 * 		If any kind off exception occurred
	 */
	public MovieInfo getMovieInfo() throws Exception {
		URL latestMovieUrl = getUrl();
		MovieInfo movieInfo = getJsonObject(latestMovieUrl, MovieInfo.class);
		return movieInfo;
	}
}
